﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web.Http

Public Module WebApiConfig
    Public Sub Register(ByVal config As HttpConfiguration)
        ' Web API configuration and services

        ' Web API routes
        config.MapHttpAttributeRoutes()



        config.Routes.MapHttpRoute(
            name:="DefaultApi",
            routeTemplate:="api/{controller}/{id}",
            defaults:=New With {.id = RouteParameter.Optional}
        )

        Dim json = config.Formatters.JsonFormatter
        json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
        json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects
        'json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented
        ' json.SerializerSettings.ContractResolver = New CamelCasePropertyNamesContractResolver()
        config.Formatters.Remove(config.Formatters.XmlFormatter)
    End Sub
End Module
